using System;
using SoftwareMonkeys.Scriptech.Stores;
using System.IO;

namespace SoftwareMonkeys.Scriptech.Projects
{
	public class ProjectGroupReader
	{
		public static ProjectGroupCollection GetGroups (string storeName)
		{
			ProjectGroupCollection groups = new ProjectGroupCollection();
			
			string storePath = StoreFileNamer.GetStorePath(storeName);
			
			foreach (string groupPath in Directory.GetDirectories (storePath)) {
				ProjectGroup projectGroup = new ProjectGroup();
				
				string name = Path.GetFileName (groupPath);
				
				projectGroup.Name = name;
				projectGroup.RootPath = groupPath;
				
				groups.Add (name, projectGroup);
			}
			
			return groups;
			
			
		}
		
		
		public static ProjectGroup GetGroup(string storeName, string groupName)
		{
			return GetGroups(storeName)[groupName];
		}
	}
}

